package org.test.memcache;

import java.io.IOException;
import java.net.InetSocketAddress;

import javax.servlet.http.HttpSession;

import net.spy.memcached.MemcachedClient;

public class MemcacheThread extends Thread {
	public static Long time=0l;

	@Override
	public void run() {
        MemcachedClient c = null;
		try {
			long start=System.currentTimeMillis();
			c = new MemcachedClient(new InetSocketAddress(Constant.HOST, Constant.PORT));
//			System.out.println(((HttpSession)c.get(Constant.KEY)).getAttribute("ACEGI_SECURITY_LAST_USERNAME"));
			System.out.println(c.get(Constant.KEY));
			long end =System.currentTimeMillis();
			synchronized(time){
				long temp=time;
				temp+=end-start;
				time=temp;
			}
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			if(c!=null){
				c.shutdown();
			}
		}
	}

}
